home *** CD-ROM | disk | FTP | other *** search
/ Amiga Tools 3 / Amiga Tools 3.iso / grafik / raytracing / rayshade-4.0.6.3 / libray / libtext / blotch.c next >
Encoding:
C/C++ Source or Header  |  1994-08-09  |  1.5 KB  |  71 lines

  1. /*
  2.  * blotch.c
  3.  *
  4.  * Copyright (C) 1989, 1991, Craig E. Kolb
  5.  * All rights reserved.
  6.  *
  7.  * This software may be freely copied, modified, and redistributed
  8.  * provided that this copyright notice is preserved on all copies.
  9.  *
  10.  * You may not distribute this software, in whole or in part, as part of
  11.  * any commercial product without the express consent of the authors.
  12.  *
  13.  * There is no warranty or other guarantee of fitness of this software
  14.  * for any purpose.  It is provided solely "as is".
  15.  *
  16.  * blotch.c,v 4.1 1994/08/09 08:02:07 explorer Exp
  17.  *
  18.  * blotch.c,v
  19.  * Revision 4.1  1994/08/09  08:02:07  explorer
  20.  * Bump version to 4.1
  21.  *
  22.  * Revision 1.1.1.1  1994/08/08  04:52:13  explorer
  23.  * Initial import.  This is a prerelease of 4.0.6enh3, or 4.1 possibly.
  24.  *
  25.  * Revision 4.0  91/07/17  14:41:31  kolb
  26.  * Initial version.
  27.  * 
  28.  */
  29. #include "texture.h"
  30. #include "blotch.h"
  31.  
  32. /*
  33.  * Create and return a reference to a "blotch" texture.
  34.  */
  35. Blotch *
  36. BlotchCreate(mix, surf)
  37. Float mix;
  38. Surface *surf;
  39. {
  40.     Blotch *blotch;
  41.  
  42.     blotch = (Blotch *)Malloc(sizeof(Blotch));
  43.     blotch->mix = mix;
  44.     blotch->surf = surf;
  45.     return blotch;
  46. }
  47.  
  48. /*
  49.  * Apply "blotch" texture.
  50.  */
  51. /*ARGSUSED*/
  52. void
  53. BlotchApply(blotch, prim, ray, pos, norm, gnorm, surf)
  54. Blotch *blotch;
  55. Geom *prim;
  56. Ray *ray;
  57. Vector *pos, *norm, *gnorm;
  58. Surface *surf;
  59. {
  60.     Float val;
  61.  
  62.     /*
  63.      * "mix" represents the 'average' noise value at a point.
  64.      */
  65.     val = Noise3(pos);
  66.     if (val > blotch->mix) {
  67.         val = (val - blotch->mix) / (1. - blotch->mix);
  68.         SurfaceBlend(surf, blotch->surf, 1. - val, val);
  69.     }
  70. }
  71.